--
-- PostgreSQL database dump
--

-- Dumped from database version 9.0.4
-- Dumped by pg_dump version 9.0.4
-- Started on 2012-11-13 23:45:33 AMST

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

SET search_path = treinamento, pg_catalog;

ALTER TABLE ONLY treinamento.trein_func DROP CONSTRAINT trein_func_instituicao_fkey;
ALTER TABLE ONLY treinamento.trein_func DROP CONSTRAINT trein_func_id_treinamento_fkey;
ALTER TABLE ONLY treinamento.trein_func DROP CONSTRAINT trein_func_id_funcionario_fkey;
ALTER TABLE ONLY treinamento.setor_trein DROP CONSTRAINT setor_trein_id_treinamento_fkey;
ALTER TABLE ONLY treinamento.setor_trein DROP CONSTRAINT setor_trein_id_setor_fkey;
ALTER TABLE ONLY treinamento.funcao_trein DROP CONSTRAINT funcao_trein_id_treinamento_fkey;
ALTER TABLE ONLY treinamento.funcao_trein DROP CONSTRAINT funcao_trein_id_funcao_fkey;
ALTER TABLE ONLY treinamento.cnae_trein DROP CONSTRAINT cnae_trein_id_treinamento_fkey;
ALTER TABLE ONLY treinamento.cnae_trein DROP CONSTRAINT cnae_trein_cnae_fkey;
ALTER TABLE ONLY treinamento.ativ_trein DROP CONSTRAINT ativ_trein_id_treinamento_fkey;
ALTER TABLE ONLY treinamento.ativ_trein DROP CONSTRAINT ativ_trein_id_atividade_fkey;
ALTER TABLE ONLY treinamento.aso_func DROP CONSTRAINT aso_func_id_funcionario_fkey;
ALTER TABLE ONLY treinamento.aso_func DROP CONSTRAINT aso_func_id_entidade_fkey;
ALTER TABLE ONLY treinamento.aso_func DROP CONSTRAINT aso_func_id_aso_fkey;
SET search_path = public, pg_catalog;

ALTER TABLE ONLY public.sugestoes DROP CONSTRAINT sugestoes_treinamento_fkey;
ALTER TABLE ONLY public.sugestoes DROP CONSTRAINT sugestoes_funcionario_fkey;
ALTER TABLE ONLY public.sugestoes DROP CONSTRAINT sugestoes_entidade_fkey;
ALTER TABLE ONLY public.logs DROP CONSTRAINT logs_usuario_fkey;
ALTER TABLE ONLY public.configuracao DROP CONSTRAINT fk_treinamento;
ALTER TABLE ONLY public.configuracao DROP CONSTRAINT fk_programa;
SET search_path = programa, pg_catalog;

ALTER TABLE ONLY programa.programa_entidade DROP CONSTRAINT programa_entidade_id_programa_fkey;
ALTER TABLE ONLY programa.programa_entidade DROP CONSTRAINT programa_entidade_id_entidade_fkey;
SET search_path = entidade, pg_catalog;

ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_setor_fkey;
ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_id_funcionario_fkey;
ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_id_entidade_fkey;
ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_id_atividade_fkey;
ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_funcao_fkey;
SET search_path = cadastro, pg_catalog;

ALTER TABLE ONLY cadastro.usuario DROP CONSTRAINT usuario_entidade_fkey;
ALTER TABLE ONLY cadastro.telefones DROP CONSTRAINT telefones_id_ent_fkey;
ALTER TABLE ONLY cadastro.entidade DROP CONSTRAINT entidade_cnae_fkey;
ALTER TABLE ONLY cadastro.entidade DROP CONSTRAINT entidade_cidade_fkey;
ALTER TABLE ONLY cadastro.entidade DROP CONSTRAINT entidade_cep_fkey;
ALTER TABLE ONLY cadastro.ceps DROP CONSTRAINT ceps_cod_cid_fkey;
SET search_path = treinamento, pg_catalog;

ALTER TABLE ONLY treinamento.trein_func DROP CONSTRAINT trein_func_pkey;
ALTER TABLE ONLY treinamento.setor_trein DROP CONSTRAINT setor_trein_pkey;
ALTER TABLE ONLY treinamento.funcao_trein DROP CONSTRAINT funcao_trein_pkey;
ALTER TABLE ONLY treinamento.cnae_trein DROP CONSTRAINT cnae_trein_pkey;
ALTER TABLE ONLY treinamento.ativ_trein DROP CONSTRAINT ativ_trein_pkey;
ALTER TABLE ONLY treinamento.aso_func DROP CONSTRAINT aso_func_pkey;
SET search_path = public, pg_catalog;

ALTER TABLE ONLY public.logs DROP CONSTRAINT logs_pkey;
ALTER TABLE ONLY public.configuracao DROP CONSTRAINT configuracao_pkey;
SET search_path = programa, pg_catalog;

ALTER TABLE ONLY programa.programa_entidade DROP CONSTRAINT programa_entidade_pkey;
SET search_path = entidade, pg_catalog;

ALTER TABLE ONLY entidade.emp_func DROP CONSTRAINT emp_func_pkey;
SET search_path = cadastro, pg_catalog;

ALTER TABLE ONLY cadastro.usuario DROP CONSTRAINT usuario_pkey;
ALTER TABLE ONLY cadastro.treinamento DROP CONSTRAINT treinamento_pkey;
ALTER TABLE ONLY cadastro.tp_aso DROP CONSTRAINT tp_aso_pkey;
ALTER TABLE ONLY cadastro.telefones DROP CONSTRAINT telefones_pkey;
ALTER TABLE ONLY cadastro.telefones DROP CONSTRAINT telefones_id_ent_tipo_key;
ALTER TABLE ONLY cadastro.setor DROP CONSTRAINT setor_pkey;
ALTER TABLE ONLY cadastro.programas DROP CONSTRAINT programas_pkey;
ALTER TABLE ONLY cadastro.municipio DROP CONSTRAINT municipio_pkey;
ALTER TABLE ONLY cadastro.instituicao DROP CONSTRAINT instituicao_pkey;
ALTER TABLE ONLY cadastro.funcionario DROP CONSTRAINT funcionario_pkey;
ALTER TABLE ONLY cadastro.funcionario DROP CONSTRAINT funcionario_cpf_key;
ALTER TABLE ONLY cadastro.funcao DROP CONSTRAINT funcao_pkey;
ALTER TABLE ONLY cadastro.entidade DROP CONSTRAINT entidade_pkey;
ALTER TABLE ONLY cadastro.entidade DROP CONSTRAINT entidade_cnpj_key;
ALTER TABLE ONLY cadastro.cnae DROP CONSTRAINT cnae_pkey;
ALTER TABLE ONLY cadastro.ceps DROP CONSTRAINT ceps_pkey;
ALTER TABLE ONLY cadastro.ceps DROP CONSTRAINT ceps_cep_key;
ALTER TABLE ONLY cadastro.atividade DROP CONSTRAINT atividade_pkey;
SET search_path = public, pg_catalog;

ALTER TABLE public.configuracao ALTER COLUMN id DROP DEFAULT;
SET search_path = cadastro, pg_catalog;

ALTER TABLE cadastro.usuario ALTER COLUMN id_user DROP DEFAULT;
ALTER TABLE cadastro.treinamento ALTER COLUMN id_treinamento DROP DEFAULT;
ALTER TABLE cadastro.tp_aso ALTER COLUMN id DROP DEFAULT;
ALTER TABLE cadastro.telefones ALTER COLUMN id_tel DROP DEFAULT;
ALTER TABLE cadastro.setor ALTER COLUMN id_setor DROP DEFAULT;
ALTER TABLE cadastro.programas ALTER COLUMN id_programa DROP DEFAULT;
ALTER TABLE cadastro.instituicao ALTER COLUMN id_inst DROP DEFAULT;
ALTER TABLE cadastro.funcionario ALTER COLUMN id_fun DROP DEFAULT;
ALTER TABLE cadastro.funcao ALTER COLUMN id_funcao DROP DEFAULT;
ALTER TABLE cadastro.entidade ALTER COLUMN id_ent DROP DEFAULT;
ALTER TABLE cadastro.ceps ALTER COLUMN id_cep DROP DEFAULT;
ALTER TABLE cadastro.atividade ALTER COLUMN id DROP DEFAULT;
SET search_path = treinamento, pg_catalog;

DROP TABLE treinamento.trein_func;
DROP TABLE treinamento.setor_trein;
DROP TABLE treinamento.funcao_trein;
DROP TABLE treinamento.cnae_trein;
DROP TABLE treinamento.ativ_trein;
DROP TABLE treinamento.aso_func;
SET search_path = public, pg_catalog;

DROP TABLE public.sugestoes;
DROP TABLE public.logs;
DROP SEQUENCE public.configuracao_id_seq;
DROP TABLE public.configuracao;
SET search_path = programa, pg_catalog;

DROP TABLE programa.programa_entidade;
SET search_path = entidade, pg_catalog;

DROP TABLE entidade.emp_func;
SET search_path = cadastro, pg_catalog;

DROP SEQUENCE cadastro.usuario_id_user_seq;
DROP TABLE cadastro.usuario;
DROP SEQUENCE cadastro.treinamento_id_treinamento_seq;
DROP TABLE cadastro.treinamento;
DROP SEQUENCE cadastro.tp_aso_id_seq;
DROP TABLE cadastro.tp_aso;
DROP SEQUENCE cadastro.telefones_id_tel_seq;
DROP TABLE cadastro.telefones;
DROP SEQUENCE cadastro.setor_id_setor_seq;
DROP TABLE cadastro.setor;
DROP SEQUENCE cadastro.programas_id_programa_seq;
DROP TABLE cadastro.programas;
DROP TABLE cadastro.municipio;
DROP SEQUENCE cadastro.instituicao_id_inst_seq;
DROP TABLE cadastro.instituicao;
DROP SEQUENCE cadastro.funcionario_id_fun_seq;
DROP TABLE cadastro.funcionario;
DROP SEQUENCE cadastro.funcao_id_funcao_seq;
DROP TABLE cadastro.funcao;
DROP SEQUENCE cadastro.entidade_id_ent_seq;
DROP TABLE cadastro.entidade;
DROP TABLE cadastro.cnae;
DROP SEQUENCE cadastro.ceps_id_cep_seq;
DROP TABLE cadastro.ceps;
DROP SEQUENCE cadastro.atividade_id_seq;
DROP TABLE cadastro.atividade;
DROP PROCEDURAL LANGUAGE plpgsql;
DROP SCHEMA treinamento;
DROP SCHEMA public;
DROP SCHEMA programa;
DROP SCHEMA entidade;
DROP SCHEMA cadastro;
--
-- TOC entry 7 (class 2615 OID 25494)
-- Name: cadastro; Type: SCHEMA; Schema: -; Owner: alcione_ctpst
--

CREATE SCHEMA cadastro;


ALTER SCHEMA cadastro OWNER TO alcione_ctpst;

--
-- TOC entry 8 (class 2615 OID 25831)
-- Name: entidade; Type: SCHEMA; Schema: -; Owner: alcione_ctpst
--

CREATE SCHEMA entidade;


ALTER SCHEMA entidade OWNER TO alcione_ctpst;

--
-- TOC entry 10 (class 2615 OID 25913)
-- Name: programa; Type: SCHEMA; Schema: -; Owner: alcione_ctpst
--

CREATE SCHEMA programa;


ALTER SCHEMA programa OWNER TO alcione_ctpst;

--
-- TOC entry 5 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO postgres;

--
-- TOC entry 1991 (class 0 OID 0)
-- Dependencies: 5
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'standard public schema';


--
-- TOC entry 9 (class 2615 OID 25847)
-- Name: treinamento; Type: SCHEMA; Schema: -; Owner: alcione_ctpst
--

CREATE SCHEMA treinamento;


ALTER SCHEMA treinamento OWNER TO alcione_ctpst;

--
-- TOC entry 375 (class 2612 OID 11574)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres;

SET search_path = cadastro, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1603 (class 1259 OID 56527)
-- Dependencies: 7
-- Name: atividade; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE atividade (
    id integer NOT NULL,
    descricao character varying(200)
);


ALTER TABLE cadastro.atividade OWNER TO alcione_ctpst;

--
-- TOC entry 1602 (class 1259 OID 56525)
-- Dependencies: 7 1603
-- Name: atividade_id_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE atividade_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.atividade_id_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1993 (class 0 OID 0)
-- Dependencies: 1602
-- Name: atividade_id_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE atividade_id_seq OWNED BY atividade.id;


--
-- TOC entry 1570 (class 1259 OID 25523)
-- Dependencies: 7
-- Name: ceps; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE ceps (
    id_cep integer NOT NULL,
    cep character(9),
    tp_logradouro character varying(20),
    logradouro character varying(70),
    bairro character varying(72),
    cod_cid integer
);


ALTER TABLE cadastro.ceps OWNER TO alcione_ctpst;

--
-- TOC entry 1569 (class 1259 OID 25521)
-- Dependencies: 1570 7
-- Name: ceps_id_cep_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE ceps_id_cep_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.ceps_id_cep_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1994 (class 0 OID 0)
-- Dependencies: 1569
-- Name: ceps_id_cep_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE ceps_id_cep_seq OWNED BY ceps.id_cep;


--
-- TOC entry 1568 (class 1259 OID 25515)
-- Dependencies: 7
-- Name: cnae; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE cnae (
    codigo character(10) NOT NULL,
    descricao character varying(256)
);


ALTER TABLE cadastro.cnae OWNER TO alcione_ctpst;

--
-- TOC entry 1572 (class 1259 OID 25642)
-- Dependencies: 1884 7
-- Name: entidade; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE entidade (
    id_ent integer NOT NULL,
    cnpj character(15),
    razao character varying(255),
    denominacao character varying(255),
    rua character varying(255),
    numero character varying(10),
    bairro character varying(100),
    cep integer,
    cidade integer,
    cnae character(10),
    data_fundacao date,
    contato character varying(200),
    e_mail character varying(300),
    data_atualizacao date,
    observacao text,
    tst character varying(255),
    tipo integer,
    CONSTRAINT entidade_tipo_check CHECK (((tipo >= 1) AND (tipo <= 2)))
);


ALTER TABLE cadastro.entidade OWNER TO alcione_ctpst;

--
-- TOC entry 1571 (class 1259 OID 25640)
-- Dependencies: 1572 7
-- Name: entidade_id_ent_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE entidade_id_ent_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.entidade_id_ent_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1995 (class 0 OID 0)
-- Dependencies: 1571
-- Name: entidade_id_ent_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE entidade_id_ent_seq OWNED BY entidade.id_ent;


--
-- TOC entry 1580 (class 1259 OID 25704)
-- Dependencies: 7
-- Name: funcao; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE funcao (
    id_funcao integer NOT NULL,
    descricao character varying(255)
);


ALTER TABLE cadastro.funcao OWNER TO alcione_ctpst;

--
-- TOC entry 1579 (class 1259 OID 25702)
-- Dependencies: 1580 7
-- Name: funcao_id_funcao_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE funcao_id_funcao_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.funcao_id_funcao_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1996 (class 0 OID 0)
-- Dependencies: 1579
-- Name: funcao_id_funcao_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE funcao_id_funcao_seq OWNED BY funcao.id_funcao;


--
-- TOC entry 1576 (class 1259 OID 25686)
-- Dependencies: 7
-- Name: funcionario; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE funcionario (
    id_fun integer NOT NULL,
    cpf character varying(12),
    nome character varying(255),
    rg character varying(50),
    org_exp character varying(10)
);


ALTER TABLE cadastro.funcionario OWNER TO alcione_ctpst;

--
-- TOC entry 1575 (class 1259 OID 25684)
-- Dependencies: 1576 7
-- Name: funcionario_id_fun_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE funcionario_id_fun_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.funcionario_id_fun_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1997 (class 0 OID 0)
-- Dependencies: 1575
-- Name: funcionario_id_fun_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE funcionario_id_fun_seq OWNED BY funcionario.id_fun;


--
-- TOC entry 1584 (class 1259 OID 25720)
-- Dependencies: 7
-- Name: instituicao; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE instituicao (
    id_inst integer NOT NULL,
    nome character varying(255)
);


ALTER TABLE cadastro.instituicao OWNER TO alcione_ctpst;

--
-- TOC entry 1583 (class 1259 OID 25718)
-- Dependencies: 7 1584
-- Name: instituicao_id_inst_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE instituicao_id_inst_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.instituicao_id_inst_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1998 (class 0 OID 0)
-- Dependencies: 1583
-- Name: instituicao_id_inst_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE instituicao_id_inst_seq OWNED BY instituicao.id_inst;


--
-- TOC entry 1567 (class 1259 OID 25498)
-- Dependencies: 7
-- Name: municipio; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE municipio (
    estado character(2),
    cod_cid integer NOT NULL,
    nome character varying(200)
);


ALTER TABLE cadastro.municipio OWNER TO alcione_ctpst;

--
-- TOC entry 1586 (class 1259 OID 25728)
-- Dependencies: 7
-- Name: programas; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE programas (
    id_programa integer NOT NULL,
    descricao character varying(255),
    validade integer,
    aviso integer
);


ALTER TABLE cadastro.programas OWNER TO alcione_ctpst;

--
-- TOC entry 1585 (class 1259 OID 25726)
-- Dependencies: 7 1586
-- Name: programas_id_programa_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE programas_id_programa_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.programas_id_programa_seq OWNER TO alcione_ctpst;

--
-- TOC entry 1999 (class 0 OID 0)
-- Dependencies: 1585
-- Name: programas_id_programa_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE programas_id_programa_seq OWNED BY programas.id_programa;


--
-- TOC entry 1578 (class 1259 OID 25696)
-- Dependencies: 7
-- Name: setor; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE setor (
    id_setor integer NOT NULL,
    descricao character varying(255)
);


ALTER TABLE cadastro.setor OWNER TO alcione_ctpst;

--
-- TOC entry 1577 (class 1259 OID 25694)
-- Dependencies: 7 1578
-- Name: setor_id_setor_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE setor_id_setor_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.setor_id_setor_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2000 (class 0 OID 0)
-- Dependencies: 1577
-- Name: setor_id_setor_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE setor_id_setor_seq OWNED BY setor.id_setor;


--
-- TOC entry 1574 (class 1259 OID 25671)
-- Dependencies: 7
-- Name: telefones; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE telefones (
    id_tel integer NOT NULL,
    id_ent integer,
    tipo integer,
    numero character varying(20)
);


ALTER TABLE cadastro.telefones OWNER TO alcione_ctpst;

--
-- TOC entry 1573 (class 1259 OID 25669)
-- Dependencies: 1574 7
-- Name: telefones_id_tel_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE telefones_id_tel_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.telefones_id_tel_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2001 (class 0 OID 0)
-- Dependencies: 1573
-- Name: telefones_id_tel_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE telefones_id_tel_seq OWNED BY telefones.id_tel;


--
-- TOC entry 1600 (class 1259 OID 34063)
-- Dependencies: 7
-- Name: tp_aso; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE tp_aso (
    id integer NOT NULL,
    descricao character varying(150)
);


ALTER TABLE cadastro.tp_aso OWNER TO alcione_ctpst;

--
-- TOC entry 1599 (class 1259 OID 34061)
-- Dependencies: 1600 7
-- Name: tp_aso_id_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE tp_aso_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.tp_aso_id_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2002 (class 0 OID 0)
-- Dependencies: 1599
-- Name: tp_aso_id_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE tp_aso_id_seq OWNED BY tp_aso.id;


--
-- TOC entry 1582 (class 1259 OID 25712)
-- Dependencies: 7
-- Name: treinamento; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE treinamento (
    id_treinamento integer NOT NULL,
    descricao character varying(255),
    validade integer
);


ALTER TABLE cadastro.treinamento OWNER TO alcione_ctpst;

--
-- TOC entry 1581 (class 1259 OID 25710)
-- Dependencies: 7 1582
-- Name: treinamento_id_treinamento_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE treinamento_id_treinamento_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.treinamento_id_treinamento_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2003 (class 0 OID 0)
-- Dependencies: 1581
-- Name: treinamento_id_treinamento_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE treinamento_id_treinamento_seq OWNED BY treinamento.id_treinamento;


--
-- TOC entry 1588 (class 1259 OID 25743)
-- Dependencies: 7
-- Name: usuario; Type: TABLE; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE usuario (
    id_user integer NOT NULL,
    nome character varying(100),
    e_mail character varying(200),
    usuario character(20),
    senha character varying(255),
    nivel integer,
    entidade integer
);


ALTER TABLE cadastro.usuario OWNER TO alcione_ctpst;

--
-- TOC entry 1587 (class 1259 OID 25741)
-- Dependencies: 1588 7
-- Name: usuario_id_user_seq; Type: SEQUENCE; Schema: cadastro; Owner: alcione_ctpst
--

CREATE SEQUENCE usuario_id_user_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE cadastro.usuario_id_user_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2004 (class 0 OID 0)
-- Dependencies: 1587
-- Name: usuario_id_user_seq; Type: SEQUENCE OWNED BY; Schema: cadastro; Owner: alcione_ctpst
--

ALTER SEQUENCE usuario_id_user_seq OWNED BY usuario.id_user;


SET search_path = entidade, pg_catalog;

--
-- TOC entry 1596 (class 1259 OID 33454)
-- Dependencies: 8
-- Name: emp_func; Type: TABLE; Schema: entidade; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE emp_func (
    id_entidade integer NOT NULL,
    id_funcionario integer NOT NULL,
    funcao integer,
    setor integer,
    data_admissao date NOT NULL,
    data_opcao date,
    id_atividade integer
);


ALTER TABLE entidade.emp_func OWNER TO alcione_ctpst;

SET search_path = programa, pg_catalog;

--
-- TOC entry 1597 (class 1259 OID 33493)
-- Dependencies: 1895 10
-- Name: programa_entidade; Type: TABLE; Schema: programa; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE programa_entidade (
    id_programa integer NOT NULL,
    id_entidade integer NOT NULL,
    data_certificacao date NOT NULL,
    data_validade date,
    status boolean DEFAULT true
);


ALTER TABLE programa.programa_entidade OWNER TO alcione_ctpst;

SET search_path = public, pg_catalog;

--
-- TOC entry 1594 (class 1259 OID 33303)
-- Dependencies: 5
-- Name: configuracao; Type: TABLE; Schema: public; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE configuracao (
    id integer NOT NULL,
    validade integer,
    aviso integer,
    paginacao integer,
    data_criacao date,
    data_atualizacao date,
    criadores character varying(255),
    email_adm character varying(200),
    programa integer,
    treinamento integer
);


ALTER TABLE public.configuracao OWNER TO alcione_ctpst;

--
-- TOC entry 1593 (class 1259 OID 33301)
-- Dependencies: 1594 5
-- Name: configuracao_id_seq; Type: SEQUENCE; Schema: public; Owner: alcione_ctpst
--

CREATE SEQUENCE configuracao_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.configuracao_id_seq OWNER TO alcione_ctpst;

--
-- TOC entry 2005 (class 0 OID 0)
-- Dependencies: 1593
-- Name: configuracao_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: alcione_ctpst
--

ALTER SEQUENCE configuracao_id_seq OWNED BY configuracao.id;


--
-- TOC entry 1595 (class 1259 OID 33338)
-- Dependencies: 5
-- Name: logs; Type: TABLE; Schema: public; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE logs (
    tempo bigint NOT NULL,
    acao character varying(20),
    usuario integer,
    texto1 text,
    texto2 text
);


ALTER TABLE public.logs OWNER TO alcione_ctpst;

--
-- TOC entry 1598 (class 1259 OID 33524)
-- Dependencies: 5
-- Name: sugestoes; Type: TABLE; Schema: public; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE sugestoes (
    entidade integer,
    funcionario integer,
    treinamento integer
);


ALTER TABLE public.sugestoes OWNER TO alcione_ctpst;

SET search_path = treinamento, pg_catalog;

--
-- TOC entry 1601 (class 1259 OID 34079)
-- Dependencies: 1897 9
-- Name: aso_func; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE aso_func (
    id_entidade integer NOT NULL,
    id_funcionario integer NOT NULL,
    id_aso integer NOT NULL,
    data_cert date NOT NULL,
    data_validade date,
    renovado boolean DEFAULT false
);


ALTER TABLE treinamento.aso_func OWNER TO alcione_ctpst;

--
-- TOC entry 1604 (class 1259 OID 56533)
-- Dependencies: 9
-- Name: ativ_trein; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE ativ_trein (
    id_atividade integer NOT NULL,
    id_treinamento integer NOT NULL
);


ALTER TABLE treinamento.ativ_trein OWNER TO alcione_ctpst;

--
-- TOC entry 1590 (class 1259 OID 25868)
-- Dependencies: 9
-- Name: cnae_trein; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE cnae_trein (
    cnae character(10) NOT NULL,
    id_treinamento integer NOT NULL
);


ALTER TABLE treinamento.cnae_trein OWNER TO alcione_ctpst;

--
-- TOC entry 1592 (class 1259 OID 25898)
-- Dependencies: 9
-- Name: funcao_trein; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE funcao_trein (
    id_funcao integer NOT NULL,
    id_treinamento integer NOT NULL
);


ALTER TABLE treinamento.funcao_trein OWNER TO alcione_ctpst;

--
-- TOC entry 1591 (class 1259 OID 25883)
-- Dependencies: 9
-- Name: setor_trein; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE setor_trein (
    id_setor integer NOT NULL,
    id_treinamento integer NOT NULL
);


ALTER TABLE treinamento.setor_trein OWNER TO alcione_ctpst;

--
-- TOC entry 1589 (class 1259 OID 25848)
-- Dependencies: 1893 9
-- Name: trein_func; Type: TABLE; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

CREATE TABLE trein_func (
    id_treinamento integer NOT NULL,
    id_funcionario integer NOT NULL,
    data_realizacao date NOT NULL,
    data_validade date,
    instituicao integer,
    status boolean DEFAULT true
);


ALTER TABLE treinamento.trein_func OWNER TO alcione_ctpst;

SET search_path = cadastro, pg_catalog;

--
-- TOC entry 1898 (class 2604 OID 56530)
-- Dependencies: 1603 1602 1603
-- Name: id; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE atividade ALTER COLUMN id SET DEFAULT nextval('atividade_id_seq'::regclass);


--
-- TOC entry 1882 (class 2604 OID 25526)
-- Dependencies: 1569 1570 1570
-- Name: id_cep; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ceps ALTER COLUMN id_cep SET DEFAULT nextval('ceps_id_cep_seq'::regclass);


--
-- TOC entry 1883 (class 2604 OID 25645)
-- Dependencies: 1572 1571 1572
-- Name: id_ent; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE entidade ALTER COLUMN id_ent SET DEFAULT nextval('entidade_id_ent_seq'::regclass);


--
-- TOC entry 1888 (class 2604 OID 25707)
-- Dependencies: 1580 1579 1580
-- Name: id_funcao; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE funcao ALTER COLUMN id_funcao SET DEFAULT nextval('funcao_id_funcao_seq'::regclass);


--
-- TOC entry 1886 (class 2604 OID 25689)
-- Dependencies: 1575 1576 1576
-- Name: id_fun; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE funcionario ALTER COLUMN id_fun SET DEFAULT nextval('funcionario_id_fun_seq'::regclass);


--
-- TOC entry 1890 (class 2604 OID 25723)
-- Dependencies: 1583 1584 1584
-- Name: id_inst; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE instituicao ALTER COLUMN id_inst SET DEFAULT nextval('instituicao_id_inst_seq'::regclass);


--
-- TOC entry 1891 (class 2604 OID 25731)
-- Dependencies: 1585 1586 1586
-- Name: id_programa; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE programas ALTER COLUMN id_programa SET DEFAULT nextval('programas_id_programa_seq'::regclass);


--
-- TOC entry 1887 (class 2604 OID 25699)
-- Dependencies: 1577 1578 1578
-- Name: id_setor; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE setor ALTER COLUMN id_setor SET DEFAULT nextval('setor_id_setor_seq'::regclass);


--
-- TOC entry 1885 (class 2604 OID 25674)
-- Dependencies: 1573 1574 1574
-- Name: id_tel; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE telefones ALTER COLUMN id_tel SET DEFAULT nextval('telefones_id_tel_seq'::regclass);


--
-- TOC entry 1896 (class 2604 OID 34066)
-- Dependencies: 1599 1600 1600
-- Name: id; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE tp_aso ALTER COLUMN id SET DEFAULT nextval('tp_aso_id_seq'::regclass);


--
-- TOC entry 1889 (class 2604 OID 25715)
-- Dependencies: 1582 1581 1582
-- Name: id_treinamento; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE treinamento ALTER COLUMN id_treinamento SET DEFAULT nextval('treinamento_id_treinamento_seq'::regclass);


--
-- TOC entry 1892 (class 2604 OID 25746)
-- Dependencies: 1588 1587 1588
-- Name: id_user; Type: DEFAULT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE usuario ALTER COLUMN id_user SET DEFAULT nextval('usuario_id_user_seq'::regclass);


SET search_path = public, pg_catalog;

--
-- TOC entry 1894 (class 2604 OID 33306)
-- Dependencies: 1594 1593 1594
-- Name: id; Type: DEFAULT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE configuracao ALTER COLUMN id SET DEFAULT nextval('configuracao_id_seq'::regclass);


SET search_path = cadastro, pg_catalog;

--
-- TOC entry 1952 (class 2606 OID 56532)
-- Dependencies: 1603 1603
-- Name: atividade_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY atividade
    ADD CONSTRAINT atividade_pkey PRIMARY KEY (id);


--
-- TOC entry 1904 (class 2606 OID 25530)
-- Dependencies: 1570 1570
-- Name: ceps_cep_key; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY ceps
    ADD CONSTRAINT ceps_cep_key UNIQUE (cep);


--
-- TOC entry 1906 (class 2606 OID 25528)
-- Dependencies: 1570 1570
-- Name: ceps_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY ceps
    ADD CONSTRAINT ceps_pkey PRIMARY KEY (id_cep);


--
-- TOC entry 1902 (class 2606 OID 25519)
-- Dependencies: 1568 1568
-- Name: cnae_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY cnae
    ADD CONSTRAINT cnae_pkey PRIMARY KEY (codigo);


--
-- TOC entry 1908 (class 2606 OID 25653)
-- Dependencies: 1572 1572
-- Name: entidade_cnpj_key; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY entidade
    ADD CONSTRAINT entidade_cnpj_key UNIQUE (cnpj);


--
-- TOC entry 1910 (class 2606 OID 25651)
-- Dependencies: 1572 1572
-- Name: entidade_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY entidade
    ADD CONSTRAINT entidade_pkey PRIMARY KEY (id_ent);


--
-- TOC entry 1922 (class 2606 OID 25709)
-- Dependencies: 1580 1580
-- Name: funcao_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY funcao
    ADD CONSTRAINT funcao_pkey PRIMARY KEY (id_funcao);


--
-- TOC entry 1916 (class 2606 OID 25693)
-- Dependencies: 1576 1576
-- Name: funcionario_cpf_key; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY funcionario
    ADD CONSTRAINT funcionario_cpf_key UNIQUE (cpf);


--
-- TOC entry 1918 (class 2606 OID 25691)
-- Dependencies: 1576 1576
-- Name: funcionario_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY funcionario
    ADD CONSTRAINT funcionario_pkey PRIMARY KEY (id_fun);


--
-- TOC entry 1926 (class 2606 OID 25725)
-- Dependencies: 1584 1584
-- Name: instituicao_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY instituicao
    ADD CONSTRAINT instituicao_pkey PRIMARY KEY (id_inst);


--
-- TOC entry 1900 (class 2606 OID 25502)
-- Dependencies: 1567 1567
-- Name: municipio_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY municipio
    ADD CONSTRAINT municipio_pkey PRIMARY KEY (cod_cid);


--
-- TOC entry 1928 (class 2606 OID 25733)
-- Dependencies: 1586 1586
-- Name: programas_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY programas
    ADD CONSTRAINT programas_pkey PRIMARY KEY (id_programa);


--
-- TOC entry 1920 (class 2606 OID 25701)
-- Dependencies: 1578 1578
-- Name: setor_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY setor
    ADD CONSTRAINT setor_pkey PRIMARY KEY (id_setor);


--
-- TOC entry 1912 (class 2606 OID 25678)
-- Dependencies: 1574 1574 1574
-- Name: telefones_id_ent_tipo_key; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY telefones
    ADD CONSTRAINT telefones_id_ent_tipo_key UNIQUE (id_ent, tipo);


--
-- TOC entry 1914 (class 2606 OID 25676)
-- Dependencies: 1574 1574
-- Name: telefones_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY telefones
    ADD CONSTRAINT telefones_pkey PRIMARY KEY (id_tel);


--
-- TOC entry 1948 (class 2606 OID 34068)
-- Dependencies: 1600 1600
-- Name: tp_aso_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY tp_aso
    ADD CONSTRAINT tp_aso_pkey PRIMARY KEY (id);


--
-- TOC entry 1924 (class 2606 OID 25717)
-- Dependencies: 1582 1582
-- Name: treinamento_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY treinamento
    ADD CONSTRAINT treinamento_pkey PRIMARY KEY (id_treinamento);


--
-- TOC entry 1930 (class 2606 OID 25751)
-- Dependencies: 1588 1588
-- Name: usuario_pkey; Type: CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_pkey PRIMARY KEY (id_user);


SET search_path = entidade, pg_catalog;

--
-- TOC entry 1944 (class 2606 OID 33458)
-- Dependencies: 1596 1596 1596 1596
-- Name: emp_func_pkey; Type: CONSTRAINT; Schema: entidade; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_pkey PRIMARY KEY (id_entidade, id_funcionario, data_admissao);


SET search_path = programa, pg_catalog;

--
-- TOC entry 1946 (class 2606 OID 33497)
-- Dependencies: 1597 1597 1597 1597
-- Name: programa_entidade_pkey; Type: CONSTRAINT; Schema: programa; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY programa_entidade
    ADD CONSTRAINT programa_entidade_pkey PRIMARY KEY (id_programa, id_entidade, data_certificacao);


SET search_path = public, pg_catalog;

--
-- TOC entry 1940 (class 2606 OID 33308)
-- Dependencies: 1594 1594
-- Name: configuracao_pkey; Type: CONSTRAINT; Schema: public; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY configuracao
    ADD CONSTRAINT configuracao_pkey PRIMARY KEY (id);


--
-- TOC entry 1942 (class 2606 OID 33345)
-- Dependencies: 1595 1595
-- Name: logs_pkey; Type: CONSTRAINT; Schema: public; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY logs
    ADD CONSTRAINT logs_pkey PRIMARY KEY (tempo);


SET search_path = treinamento, pg_catalog;

--
-- TOC entry 1950 (class 2606 OID 34083)
-- Dependencies: 1601 1601 1601 1601 1601
-- Name: aso_func_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY aso_func
    ADD CONSTRAINT aso_func_pkey PRIMARY KEY (id_entidade, id_funcionario, id_aso, data_cert);


--
-- TOC entry 1954 (class 2606 OID 56537)
-- Dependencies: 1604 1604 1604
-- Name: ativ_trein_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY ativ_trein
    ADD CONSTRAINT ativ_trein_pkey PRIMARY KEY (id_atividade, id_treinamento);


--
-- TOC entry 1934 (class 2606 OID 25872)
-- Dependencies: 1590 1590 1590
-- Name: cnae_trein_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY cnae_trein
    ADD CONSTRAINT cnae_trein_pkey PRIMARY KEY (cnae, id_treinamento);


--
-- TOC entry 1938 (class 2606 OID 25902)
-- Dependencies: 1592 1592 1592
-- Name: funcao_trein_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY funcao_trein
    ADD CONSTRAINT funcao_trein_pkey PRIMARY KEY (id_funcao, id_treinamento);


--
-- TOC entry 1936 (class 2606 OID 25887)
-- Dependencies: 1591 1591 1591
-- Name: setor_trein_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY setor_trein
    ADD CONSTRAINT setor_trein_pkey PRIMARY KEY (id_setor, id_treinamento);


--
-- TOC entry 1932 (class 2606 OID 25852)
-- Dependencies: 1589 1589 1589 1589
-- Name: trein_func_pkey; Type: CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst; Tablespace: 
--

ALTER TABLE ONLY trein_func
    ADD CONSTRAINT trein_func_pkey PRIMARY KEY (id_treinamento, id_funcionario, data_realizacao);


SET search_path = cadastro, pg_catalog;

--
-- TOC entry 1955 (class 2606 OID 25531)
-- Dependencies: 1570 1567 1899
-- Name: ceps_cod_cid_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY ceps
    ADD CONSTRAINT ceps_cod_cid_fkey FOREIGN KEY (cod_cid) REFERENCES municipio(cod_cid);


--
-- TOC entry 1956 (class 2606 OID 25654)
-- Dependencies: 1905 1570 1572
-- Name: entidade_cep_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY entidade
    ADD CONSTRAINT entidade_cep_fkey FOREIGN KEY (cep) REFERENCES ceps(id_cep);


--
-- TOC entry 1957 (class 2606 OID 25659)
-- Dependencies: 1899 1572 1567
-- Name: entidade_cidade_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY entidade
    ADD CONSTRAINT entidade_cidade_fkey FOREIGN KEY (cidade) REFERENCES municipio(cod_cid);


--
-- TOC entry 1958 (class 2606 OID 25664)
-- Dependencies: 1901 1572 1568
-- Name: entidade_cnae_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY entidade
    ADD CONSTRAINT entidade_cnae_fkey FOREIGN KEY (cnae) REFERENCES cnae(codigo);


--
-- TOC entry 1959 (class 2606 OID 25679)
-- Dependencies: 1574 1572 1909
-- Name: telefones_id_ent_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY telefones
    ADD CONSTRAINT telefones_id_ent_fkey FOREIGN KEY (id_ent) REFERENCES entidade(id_ent);


--
-- TOC entry 1960 (class 2606 OID 25752)
-- Dependencies: 1588 1572 1909
-- Name: usuario_entidade_fkey; Type: FK CONSTRAINT; Schema: cadastro; Owner: alcione_ctpst
--

ALTER TABLE ONLY usuario
    ADD CONSTRAINT usuario_entidade_fkey FOREIGN KEY (entidade) REFERENCES entidade(id_ent);


SET search_path = entidade, pg_catalog;

--
-- TOC entry 1975 (class 2606 OID 33469)
-- Dependencies: 1596 1580 1921
-- Name: emp_func_funcao_fkey; Type: FK CONSTRAINT; Schema: entidade; Owner: alcione_ctpst
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_funcao_fkey FOREIGN KEY (funcao) REFERENCES cadastro.funcao(id_funcao);


--
-- TOC entry 1977 (class 2606 OID 56548)
-- Dependencies: 1951 1603 1596
-- Name: emp_func_id_atividade_fkey; Type: FK CONSTRAINT; Schema: entidade; Owner: alcione_ctpst
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_id_atividade_fkey FOREIGN KEY (id_atividade) REFERENCES cadastro.atividade(id);


--
-- TOC entry 1973 (class 2606 OID 33459)
-- Dependencies: 1596 1572 1909
-- Name: emp_func_id_entidade_fkey; Type: FK CONSTRAINT; Schema: entidade; Owner: alcione_ctpst
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_id_entidade_fkey FOREIGN KEY (id_entidade) REFERENCES cadastro.entidade(id_ent);


--
-- TOC entry 1974 (class 2606 OID 33464)
-- Dependencies: 1596 1576 1917
-- Name: emp_func_id_funcionario_fkey; Type: FK CONSTRAINT; Schema: entidade; Owner: alcione_ctpst
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_id_funcionario_fkey FOREIGN KEY (id_funcionario) REFERENCES cadastro.funcionario(id_fun);


--
-- TOC entry 1976 (class 2606 OID 33474)
-- Dependencies: 1919 1578 1596
-- Name: emp_func_setor_fkey; Type: FK CONSTRAINT; Schema: entidade; Owner: alcione_ctpst
--

ALTER TABLE ONLY emp_func
    ADD CONSTRAINT emp_func_setor_fkey FOREIGN KEY (setor) REFERENCES cadastro.setor(id_setor);


SET search_path = programa, pg_catalog;

--
-- TOC entry 1979 (class 2606 OID 33503)
-- Dependencies: 1597 1572 1909
-- Name: programa_entidade_id_entidade_fkey; Type: FK CONSTRAINT; Schema: programa; Owner: alcione_ctpst
--

ALTER TABLE ONLY programa_entidade
    ADD CONSTRAINT programa_entidade_id_entidade_fkey FOREIGN KEY (id_entidade) REFERENCES cadastro.entidade(id_ent);


--
-- TOC entry 1978 (class 2606 OID 33498)
-- Dependencies: 1597 1586 1927
-- Name: programa_entidade_id_programa_fkey; Type: FK CONSTRAINT; Schema: programa; Owner: alcione_ctpst
--

ALTER TABLE ONLY programa_entidade
    ADD CONSTRAINT programa_entidade_id_programa_fkey FOREIGN KEY (id_programa) REFERENCES cadastro.programas(id_programa);


SET search_path = public, pg_catalog;

--
-- TOC entry 1970 (class 2606 OID 34050)
-- Dependencies: 1927 1594 1586
-- Name: fk_programa; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY configuracao
    ADD CONSTRAINT fk_programa FOREIGN KEY (programa) REFERENCES cadastro.programas(id_programa);


--
-- TOC entry 1971 (class 2606 OID 34055)
-- Dependencies: 1582 1594 1923
-- Name: fk_treinamento; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY configuracao
    ADD CONSTRAINT fk_treinamento FOREIGN KEY (treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1972 (class 2606 OID 33346)
-- Dependencies: 1595 1588 1929
-- Name: logs_usuario_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY logs
    ADD CONSTRAINT logs_usuario_fkey FOREIGN KEY (usuario) REFERENCES cadastro.usuario(id_user);


--
-- TOC entry 1980 (class 2606 OID 33527)
-- Dependencies: 1598 1572 1909
-- Name: sugestoes_entidade_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY sugestoes
    ADD CONSTRAINT sugestoes_entidade_fkey FOREIGN KEY (entidade) REFERENCES cadastro.entidade(id_ent);


--
-- TOC entry 1981 (class 2606 OID 33532)
-- Dependencies: 1598 1576 1917
-- Name: sugestoes_funcionario_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY sugestoes
    ADD CONSTRAINT sugestoes_funcionario_fkey FOREIGN KEY (funcionario) REFERENCES cadastro.funcionario(id_fun);


--
-- TOC entry 1982 (class 2606 OID 33537)
-- Dependencies: 1598 1582 1923
-- Name: sugestoes_treinamento_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alcione_ctpst
--

ALTER TABLE ONLY sugestoes
    ADD CONSTRAINT sugestoes_treinamento_fkey FOREIGN KEY (treinamento) REFERENCES cadastro.treinamento(id_treinamento);


SET search_path = treinamento, pg_catalog;

--
-- TOC entry 1985 (class 2606 OID 34094)
-- Dependencies: 1601 1600 1947
-- Name: aso_func_id_aso_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY aso_func
    ADD CONSTRAINT aso_func_id_aso_fkey FOREIGN KEY (id_aso) REFERENCES cadastro.tp_aso(id);


--
-- TOC entry 1983 (class 2606 OID 34084)
-- Dependencies: 1572 1909 1601
-- Name: aso_func_id_entidade_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY aso_func
    ADD CONSTRAINT aso_func_id_entidade_fkey FOREIGN KEY (id_entidade) REFERENCES cadastro.entidade(id_ent);


--
-- TOC entry 1984 (class 2606 OID 34089)
-- Dependencies: 1601 1576 1917
-- Name: aso_func_id_funcionario_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY aso_func
    ADD CONSTRAINT aso_func_id_funcionario_fkey FOREIGN KEY (id_funcionario) REFERENCES cadastro.funcionario(id_fun);


--
-- TOC entry 1986 (class 2606 OID 56538)
-- Dependencies: 1951 1604 1603
-- Name: ativ_trein_id_atividade_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY ativ_trein
    ADD CONSTRAINT ativ_trein_id_atividade_fkey FOREIGN KEY (id_atividade) REFERENCES cadastro.atividade(id);


--
-- TOC entry 1987 (class 2606 OID 56543)
-- Dependencies: 1582 1604 1923
-- Name: ativ_trein_id_treinamento_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY ativ_trein
    ADD CONSTRAINT ativ_trein_id_treinamento_fkey FOREIGN KEY (id_treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1964 (class 2606 OID 25873)
-- Dependencies: 1590 1568 1901
-- Name: cnae_trein_cnae_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY cnae_trein
    ADD CONSTRAINT cnae_trein_cnae_fkey FOREIGN KEY (cnae) REFERENCES cadastro.cnae(codigo);


--
-- TOC entry 1965 (class 2606 OID 25878)
-- Dependencies: 1923 1590 1582
-- Name: cnae_trein_id_treinamento_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY cnae_trein
    ADD CONSTRAINT cnae_trein_id_treinamento_fkey FOREIGN KEY (id_treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1968 (class 2606 OID 25903)
-- Dependencies: 1580 1592 1921
-- Name: funcao_trein_id_funcao_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY funcao_trein
    ADD CONSTRAINT funcao_trein_id_funcao_fkey FOREIGN KEY (id_funcao) REFERENCES cadastro.funcao(id_funcao);


--
-- TOC entry 1969 (class 2606 OID 25908)
-- Dependencies: 1582 1592 1923
-- Name: funcao_trein_id_treinamento_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY funcao_trein
    ADD CONSTRAINT funcao_trein_id_treinamento_fkey FOREIGN KEY (id_treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1966 (class 2606 OID 25888)
-- Dependencies: 1578 1591 1919
-- Name: setor_trein_id_setor_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY setor_trein
    ADD CONSTRAINT setor_trein_id_setor_fkey FOREIGN KEY (id_setor) REFERENCES cadastro.setor(id_setor);


--
-- TOC entry 1967 (class 2606 OID 25893)
-- Dependencies: 1582 1923 1591
-- Name: setor_trein_id_treinamento_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY setor_trein
    ADD CONSTRAINT setor_trein_id_treinamento_fkey FOREIGN KEY (id_treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1962 (class 2606 OID 25858)
-- Dependencies: 1576 1917 1589
-- Name: trein_func_id_funcionario_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY trein_func
    ADD CONSTRAINT trein_func_id_funcionario_fkey FOREIGN KEY (id_funcionario) REFERENCES cadastro.funcionario(id_fun);


--
-- TOC entry 1961 (class 2606 OID 25853)
-- Dependencies: 1589 1923 1582
-- Name: trein_func_id_treinamento_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY trein_func
    ADD CONSTRAINT trein_func_id_treinamento_fkey FOREIGN KEY (id_treinamento) REFERENCES cadastro.treinamento(id_treinamento);


--
-- TOC entry 1963 (class 2606 OID 25863)
-- Dependencies: 1925 1589 1584
-- Name: trein_func_instituicao_fkey; Type: FK CONSTRAINT; Schema: treinamento; Owner: alcione_ctpst
--

ALTER TABLE ONLY trein_func
    ADD CONSTRAINT trein_func_instituicao_fkey FOREIGN KEY (instituicao) REFERENCES cadastro.instituicao(id_inst);


--
-- TOC entry 1992 (class 0 OID 0)
-- Dependencies: 5
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2012-11-13 23:45:34 AMST

--
-- PostgreSQL database dump complete
--

